home *** CD-ROM | disk | FTP | other *** search
- Path: www.gnofn.org!not-for-mail
- From: clm01@www.gnofn.org (Christopher L Mayeux)
- Newsgroups: comp.lang.c
- Subject: Re: Keyboard input: C's equivalent to BASIC's Inkey$
- Date: 24 Jan 1996 09:30:46 -0600
- Organization: Greater New Orleans Free-Net
- Distribution: world
- Message-ID: <4e5jb6$t81@www.gnofn.org>
- References: <Pine.SUN.3.91.960111212844.17033A@suntan> <4dbpe1$47c@news.iag.net> <Pine.A32.3.91.960114210134.59051F-100000@black.weeg.uiowa.edu>
- NNTP-Posting-Host: www.gnofn.org
- X-Newsreader: TIN [version 1.2 PL2]
-
- The Amorphous Mass (robinson@blue.weeg.uiowa.edu) wrote:
- : On 14 Jan 1996, John R Buchan wrote:
-
- : > There no ansi or truly portable equivalent. The c.l.c faq (Frequently
- : > Asked Question) list mentions several system specific possiblilties.
- : > The list is available for anonymous for from ftfm.mit.edu
-
- /* Try adding this function to the list of many... */
- /* Originally written for OS-9/6809, but can be so */
- /* converted to other platforms by changing all the*/
- /* reg.rg_ references to the target system's */
- /* */
- /* Use: inkey(fileno(stdin),character) for keyboard*/
-
- #include <stdio.h>
- #include <os9.h>
-
- inkey(path,text)
- int path;
- char text[1];
- {
- struct registers reg;
- int tester=0;
- strcpy(text,"\0");
-
- reg.rg_a=path;
- reg.rg_b=SS_READY;
- _os9(I_GETSTT,®);
- tester=reg.rg_cc & 1; /* carry bit clear if no incoming byte */
-
- if (tester == 1)
- {
- strcpy(text,"\0");
- goto quit;
- }
-
- reg.rg_a=path;
- reg.rg_y=0x01;
- reg.rg_x=text;
- _os9(I_READ,®);
-
- quit:
- text[1]='\0'; /* return a null character if no keypress */
- return text;
- }
-
- --
- *
-